﻿using UnityEngine;
using System.Collections;

///Developed By Indie Studio
///https://assetstore.unity.com/publishers/9268
///www.indiestd.com
///info@indiestd.com

namespace IndieStudio.BugsBang.Utility
{
	[DisallowMultipleComponent]
	public class TransformScale : MonoBehaviour
	{
		/// <summary>
		/// The scale mode.
		/// </summary>
		public ScaleMode scaleMode = ScaleMode.STRETCHED;

		/// <summary>
		/// The stretched scale.
		/// </summary>
		public Vector2 stretchedScale = Vector2.one;

		/// <summary>
		/// The aspect ratio scale.
		/// </summary>
		public Vector2 aspectRatioScale = Vector2.one;

		/// <summary>
		/// Whether to run the scale on start or not.
		/// </summary>
		public bool runOnStart = true;

		void Start ()
		{
			if (runOnStart) {
				Run ();
			}
		}

		/// <summary>
		/// Run the scale function.
		/// </summary>
		public void Run(){
			//Apply the scale based on the scale mode
			if (scaleMode == ScaleMode.PRESERVED) {
				PreservedScale ();
			} else if (scaleMode == ScaleMode.STRETCHED) {
				StretchedScale ();
			}
		}

		/// <summary>
		/// Scale the gameobject based on screen width and height
		/// </summary>
		private void StretchedScale ()
		{
			Vector3 worldSpaceScale = Camera.main.ScreenToWorldPoint (new Vector2 (Screen.width, Screen.height));
			transform.localScale = new Vector3 (worldSpaceScale.x * stretchedScale.x, worldSpaceScale.y * stretchedScale.y, transform.localScale.z);
		}
		
		/// <summary>
		/// Scale the gameobject based on screen aspect ratio
		/// </summary>
		private void PreservedScale ()
		{
			transform.localScale = new Vector3 (Camera.main.aspect * aspectRatioScale.x, Camera.main.aspect * aspectRatioScale.y, 1);
		}

		public enum ScaleMode
		{
			STRETCHED,
			PRESERVED
		}

        public void TEXT1()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }
        public void TEXT2()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }
        public void TEXT3()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT4()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT5()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT6()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT8()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT9()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT10()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT11()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT12()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT13()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT14()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT15()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT16()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }

        public void TEXT17()
        {
            int textNum = 1;
            if (textNum == 1)
            {
                textNum = 2;
            }
        }
    }
}